﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadFilePage.aspx.cs" Inherits="map.common.UploadFilePage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <style type ="text/css" >
        .hiddenObject
        {
            visibility:hidden ;
        } 
         .ErrorMsgP
       {
           border :solid 1px red;
           background-color:#FFF2F2;
           width:150px;       
           margin-top:3px;
       }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="UploadFileDiv">
        <asp:FileUpload ID="MainFileUpload" Width="90%"  runat="server" />
        <input  type ="hidden" value="" id="HttpFileUrlHidden" runat ="server" />
        <input type="hidden" value ="0" id="CheckedUploadFileHidden" runat="server"/>
        <input  type ="hidden" value="" id="UploadFileErrorMsgHidden" runat ="server"/>
        <input  type ="hidden" value="" id="FileNameHidden" runat ="server" />
        <asp:Button ID="SaveFileButton"  runat="server"  Text ="保存" 
            CssClass="hiddenObject " onclick="SaveFileButton_Click"/>
    </div>
    <script type ="text/javascript" >
        function getHttpFileUrl() {
            var urlHidden = document.getElementById("HttpFileUrlHidden");
            document.getElementById("CheckedUploadFileHidden").value = "0";
            return urlHidden.value;
        }
        function getFileName() {
            return document.getElementById("FileNameHidden").value;
        }
        function getUploadFileValue() {
            return document.getElementById("MainFileUpload").value;
        }
        
        function getUploadFileStatus() {
            var checkHidden = document.getElementById("CheckedUploadFileHidden");
            return checkHidden.value;
        }

        function saveFile() {              
            document.getElementById("SaveFileButton").click();
        }
        function getErrorMsg() {
            return document.getElementById("UploadFileErrorMsgHidden").value;
        }

        function showFileError(errorMsg,hasError) {
            var _UploadFileDiv = document.getElementById("UploadFileDiv");
            var pEleList = _UploadFileDiv.getElementsByTagName("p");
            if (pEleList.length > 0 && hasError != true) {
                _UploadFileDiv.removeChild(pEleList[0]);
            }
            if (pEleList.length <= 0 && hasError == true) {
                var newPEle = document.createElement("p");
                newPEle.className = "ErrorMsgP";
                newPEle.innerHTML = errorMsg;
                _UploadFileDiv.appendChild(newPEle );
            }
        }
        
    </script>
    </form>
</body>
</html>
